﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RadowCore.Models
{
    class NotEqualOp: OpNode
    {

        private bool m_isRoleType;
        /// <summary>
        /// a boolean value, determines if true, then: the equality should be between the roles of contributing nodes, 
        /// otherwise between instances of the roles.
        /// </summary>
        public bool IsRoleType
        {
            get { return m_isRoleType; }
            set { m_isRoleType = value; }
        }

        private string m_source;
        /// <summary>
        /// The source originator of the flow
        /// </summary>
        public string Source
        {
            get { return m_source; }
            set { m_source = value; }
        }
        private string m_destination;
        /// <summary>
        /// the destination originator of the flow
        /// </summary>
        public string Destination
        {
            get { return m_destination; }
            set { m_destination = value; }
        }

        /// <summary>
        /// FlowNode class constructor
        /// </summary>
        /// <param name="source">The source originator of the flow</param>
        /// <param name="destination">The destination originator of the flow</param>
        public NotEqualOp()
        {
            this.OpName = "NotEquals";
        }
        /// <summary>
        /// checks whether the roles of the the originators (or roles) of operation's operands are equal
        /// </summary>
        /// <returns>true if a flow occured, false otherwise</returns>
        public override bool Evaluate(List<PGNode> visitedNodes)
        {
            if(IsRoleType)
                return (visitedNodes[0].Role != visitedNodes[visitedNodes.Count() - 1].Role);
            else
                return (visitedNodes[0].Orignator != visitedNodes[visitedNodes.Count() - 1].Orignator);
        }

    }
}
